<script>
$(document).ready(function(){
	{params}
	var c = {
		init:function(){
			this.cnum 		= params.cnum;
			this.funids 	= params.funids;
			this.loaddata();
		},
		loaddata:function(){
			js.ajax.get({
				url:'api/company/homeme',
				cnum:this.cnum,
				data:{
					funids:this.funids
				}
			},function(ret){
				$('#refresh_{rand}').html('<i class="icon-refresh"></i>');
				c.loaddatashow(ret.data);
			});
		},
		refresh:function(){
			$('#refresh_{rand}').html(js.show.ling(30));
			this.loaddata();
		},
		loaddatashow:function(da){
			$('div[temp=homeme]').remove();
			if(usertype==2)$('#goplatdiv_{rand}').show();
			this.maindata = da;
			this.shownotice(da.notice);
			this.showschedule(da.schedule);
			this.showtodo(da.todo);
			this.showkata(da.kata);
			this.showmeet(da.meet);
			this.showflowbill(da.flowbill);
			this.showrukou(da);
			js.initbtn(this, 'main_{rand}');
			websocket_onmessage=function(d){
				if(d.type=='todo')c.refresh();
			}
		},
		shownotice:function(da){
			if(!da)return;
			this.noticedata = da;
			$('#notice_{rand}').show();
			$('#noticename_{rand}').html(da.name);
			var i,ds = da.data,s='',d;
			if(ds)for(i=0;i<ds.length;i++){
				d = ds[i];
				s+='<div temp="homeme" clickevt="xiangnotice,'+d.id+'" class="rock-list-item rock-hover">◇【'+d.typename+'】'+d.title+'<span class="hui">('+d.indate+')</span></div>';
			}
			$('#notice_{rand}').append(s);
			if(!da.color)da.color='#1CBC7F';
			get('noticetitle_{rand}').style.background=da.color;
		},
		showtodo:function(da){
			if(!da)return;
			this.tododata = da;
			$('#tododiv_{rand}').show();
			var ov = $('#todoshu{rand}');
			ov.html(da.total);
			if(da.total>0){
				ov.show();
			}else{
				ov.hide();
			}
		},
		showkata:function(da){
			if(!da)return;
			this.katadata = da;
			var i,s='',d;
			for(i=0;i<da.length;i++){
				d = da[i];
				s += this.getstrstr(d, 'openkata,'+i+'');
			}
			
			$('#kuailist_{rand}').prepend(s);
		},
		getstrstr:function(d,cli,bh){
			var s='<div temp="homeme" clickevt="'+cli+'" class="rock-border rock-radius bg-main rock-hovers cursor" align="center" style="width:110px;padding:20px 0px;float:left;margin:10px;position:relative;">';
			if(typeof(d.total)=='string'){
				var dis = (d.total=='0')?'none':'';
				s+='<span style="position:absolute;top:1px;right:1px;border-radius:10px;background:red;padding:2px 6px;display:'+dis+'" class="rock-badge" id="'+bh+'_total{rand}">'+d.total+'</span>';
			}
			if(d.icon){
				s+='<div style="height:40px;overflow:hidden;font-size:30px" class="white"><i class="icon-'+d.icon+'"></i></div>';
			}else{
				s+='<div style="height:40px;overflow:hidden"><img style="border-radius:5px" src="'+d.icons+'" height="30px" width="30px"></div>';
			}
			s+='<div class="white">'+d.name+'</div>';
			s+='</div>';
			return s;
		},
		showrukou:function(da){
			var d,i,s='';
			for(i in da){
				d = da[i];
				if(typeof(d.total)=='string'){
					s += this.getstrstr(d,'morerukou,'+i+'',i);
				}
			}
			if(usertype==2)s += this.getstrstr({name:'平台管理',num:'plat',icon:'home'},'morerukou,plat','plat');
			if(s)$('#kuailist_{rand}').prepend(s);
		},
		showschedule:function(da){
			if(!da)return;
			this.scheduledata = da;
			$('#schedule_{rand}').show();
			$('#schedulename_{rand}').html(da.name+'('+da.date+')');
			var i,ds = da.data,s='',d;
			if(ds)for(i=0;i<ds.length;i++){
				d = ds[i];
				s+='<div temp="homeme" clickevt="xiangschedule,'+d.id+'" class="rock-list-item rock-hover">◇ ';
				if(d.typename)s+='<span style="color:'+d.typecolor+'">'+d.typename+'.</span>';
				s+=''+d.title+'<span class="hui">('+d.time.substr(11,5)+')</span></div>';
			}
			$('#schedule_{rand}').append(s);
			if(!da.color)da.color='#1CBC7F';
			get('scheduletitle_{rand}').style.background=da.color;
		},
		showmeet:function(da){
			if(!da)return;
			this.meetdata = da;
			$('#meet_{rand}').show();
			var i,ds = da.data,s='',d;
			if(ds)for(i=0;i<ds.length;i++){
				d = ds[i];
				s+='<div temp="homeme" clickevt="xiangmeet,'+d.id+'" class="rock-list-item rock-hover">◇ ';
				s+='['+d.meethys+']'+d.title+'<span style="color:'+d.state_color+'">('+d.state_textcn+')</span><div style="padding-left:15px;color:#888888;font-size:12px">'+d.startdt+'→'+d.enddt+'</div></div>';
			}
			$('#meet_{rand}').append(s);
			if(!da.color)da.color='#fc6419';
			get('meettitle_{rand}').style.background=da.color;
		},
		showflowbill:function(da){
			if(!da)return;
			this.flowbilldata = da;
			$('#flowbill_{rand}').show();
			var i,ds = da.data,s='',d;
			$('#flowbillname_{rand}').html(da.name+'('+da.zongshu+')');
			if(ds)for(i=0;i<ds.length;i++){
				d = ds[i];
				s+='<div temp="homeme" clickevt="xiangbill,'+i+'" class="rock-list-item rock-hover">◇ ';
				s+='【'+d.fmodename+'】'+d.content+'('+d.applydt+')，<span style="color:'+d.status_color+'">'+d.status_textcn.replace('?', d.nowcheckname)+'</span></div>';
			}
			$('#flowbill_{rand}').append(s);
		},
		xiangnotice:function(o1,id){
			xcy.openxiang({
				num:'notice',
				mid:id,
				cnum:this.cnum,
				funitid:this.noticedata.funitid,
				xiangwidth:700,
				ismodal:true
			});
		},
		xiangmeet:function(o1,id){
			xcy.openxiang({
				num:'meet',
				mid:id,
				cnum:this.cnum,
				funitid:this.meetdata.funitid,
				ismodal:true
			});
		},
		xiangschedule:function(o1,id){
			xcy.openxiang({
				num:'schedule',
				mid:id,
				cnum:this.cnum,
				funitid:this.scheduledata.funitid,
				ismodal:true
			});
		},
		xiangbill:function(oi,i){
			var d = this.flowbilldata.data[i];
			xcy.openxiang({
				num:d.fmodenum,
				mid:d.mid,
				cnum:this.cnum,
				funitid:d.fmodeid,
				ismodal:true
			});
		},
		noticemore:function(){
			this.more({
				num:'notice',
				name:this.noticedata.name,
				id:this.noticedata.funitid
			});
		},
		schedulemore:function(){
			this.more({
				num:'schedule',
				name:this.scheduledata.name,
				id:this.scheduledata.funitid
			});
		},
		morerukou:function(o1,bh){
			if(bh=='plat'){
				xcy.openkey({url:'home'});
				return;
			}
			var d = this.maindata[bh];
			this.more({
				num:d.num,
				name:d.name,
				pnum:d.pnum,
				id:d.funitid
			});
			$('#'+bh+'_total{rand}').hide();
		},
		meetmore:function(){
			this.more({
				num:'meet',
				name:this.meetdata.name,
				id:this.meetdata.funitid
			});
		},
		flowbillmore:function(){
			this.more({
				num:'flowbill',
				name:this.flowbilldata.name,
				id:this.flowbilldata.funitid
			});
		},
		more:function(d){
			if(!d.pnum)d.pnum='';
			var cans = {num:d.num+this.cnum+d.pnum,name:d.name,url:'flow/list',params:{num:d.num,cnum:this.cnum,otype:'company',funitid:d.id,pnum:d.pnum}};
			addtabs(cans);
		},
		openkata:function(o1,i){
			var d = this.katadata[i];
			window.open(d.url);
		}
	}

	c.init();
});
</script>

<div id="main_{rand}">
		
	<div >
		<div style="display:inline-block;padding:0px 10px;" id="kuailist_{rand}">
			<div clickevt="refresh" class="rock-border rock-radius bg-main rock-hovers cursor" align="center" style="width:110px;padding:20px 0px;float:left;margin:10px;">
				<div id="refresh_{rand}" style="height:40px;overflow:hidden;font-size:30px" class="white"><i class="icon-refresh"></i></div>
				<div class="white">刷新</div>
			</div>
		</div>
	</div>		
		
	<div style="display:inline-block">
	
		<div align="left" id="flowbill_{rand}" style="margin:10px;min-width:300px;float:left;display:none"  class="rock-panel rock-border rock-radius rock-list-group">
			<div class="rock-list-item">
				<span id="flowbillname_{rand}">我的申请(0)</span>
				<font><a clickevt="flowbillmore" href="javascript:;">更多&gt;&gt;</a></font>
			</div>
		</div>
		
		<div align="left" id="notice_{rand}" style="margin:10px;min-width:250px;float:left;display:none"  class="rock-panel rock-border rock-radius rock-list-group">
			<div class="rock-list-item white" id="noticetitle_{rand}">
				<span id="noticename_{rand}"></span>
				<font><a clickevt="noticemore" href="javascript:;" class="white">更多&gt;&gt;</a></font>
			</div>
			
		</div>
		
		<div align="left" id="schedule_{rand}" style="margin:10px;min-width:300px;float:left;display:none"  class="rock-panel rock-border rock-radius rock-list-group">
			<div class="rock-list-item white" id="scheduletitle_{rand}">
				<span id="schedulename_{rand}">今日日程</span>
				<font><a clickevt="schedulemore" href="javascript:;" class="white">更多&gt;&gt;</a></font>
			</div>
		</div>
		
		<div align="left" id="meet_{rand}" style="margin:10px;min-width:300px;float:left;display:none"  class="rock-panel rock-border rock-radius rock-list-group">
			<div class="rock-list-item white" id="meettitle_{rand}">
				<span id="meetname_{rand}">今日会议</span>
				<font><a clickevt="meetmore" href="javascript:;" class="white">更多&gt;&gt;</a></font>
			</div>
		</div>
	
	</div>
</div>